/*
 * $Id: vlan.h,v 1.134.2.5 Broadcom SDK $
 * 
 * $Copyright: Copyright 2011 Broadcom Corporation.
 * This program is the proprietary software of Broadcom Corporation
 * and/or its licensors, and may only be used, duplicated, modified
 * or distributed pursuant to the terms and conditions of a separate,
 * written license agreement executed between you and Broadcom
 * (an "Authorized License").  Except as set forth in an Authorized
 * License, Broadcom grants no license (express or implied), right
 * to use, or waiver of any kind with respect to the Software, and
 * Broadcom expressly reserves all rights in and to the Software
 * and all intellectual property rights therein.  IF YOU HAVE
 * NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS SOFTWARE
 * IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
 * ALL USE OF THE SOFTWARE.  
 *  
 * Except as expressly set forth in the Authorized License,
 *  
 * 1.     This program, including its structure, sequence and organization,
 * constitutes the valuable trade secrets of Broadcom, and you shall use
 * all reasonable efforts to protect the confidentiality thereof,
 * and to use this information only in connection with your use of
 * Broadcom integrated circuit products.
 *  
 * 2.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS
 * PROVIDED "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
 * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
 * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE.  BROADCOM SPECIFICALLY
 * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
 * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
 * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
 * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING
 * OUT OF USE OR PERFORMANCE OF THE SOFTWARE.
 * 
 * 3.     TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL
 * BROADCOM OR ITS LICENSORS BE LIABLE FOR (i) CONSEQUENTIAL,
 * INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY DAMAGES WHATSOEVER
 * ARISING OUT OF OR IN ANY WAY RELATING TO YOUR USE OF OR INABILITY
 * TO USE THE SOFTWARE EVEN IF BROADCOM HAS BEEN ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGES; OR (ii) ANY AMOUNT IN EXCESS OF
 * THE AMOUNT ACTUALLY PAID FOR THE SOFTWARE ITSELF OR USD 1.00,
 * WHICHEVER IS GREATER. THESE LIMITATIONS SHALL APPLY NOTWITHSTANDING
 * ANY FAILURE OF ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.$
 * 
 * DO NOT EDIT THIS FILE!
 * This file is auto-generated.
 * Edits to this file will be lost when it is regenerated.
 */

#ifndef __BCM_VLAN_H__
#define __BCM_VLAN_H__

#include <bcm/types.h>
#include <bcm/multicast.h>
#include <bcm/policer.h>
#include <bcm/port.h>

#define BCM_VLAN_VID_DISABLE    BCM_VLAN_INVALID 

/* Initialize a VLAN data information structure. */
typedef struct bcm_vlan_data_s {
    bcm_vlan_t vlan_tag; 
    bcm_pbmp_t port_bitmap; 
    bcm_pbmp_t ut_port_bitmap; 
} bcm_vlan_data_t;

/* Backward compatibility: Do not use. */
typedef bcm_vlan_data_t vlan_data_t;

#ifndef BCM_HIDE_DISPATCHABLE

/* Initialize the VLAN module. */
extern int bcm_vlan_init(
    int unit);

/* Allocate and configure a VLAN on the BCM device. */
extern int bcm_vlan_create(
    int unit, 
    bcm_vlan_t vid);

/* Deallocate VLAN from the BCM device. */
extern int bcm_vlan_destroy(
    int unit, 
    bcm_vlan_t vid);

/* Destroy all VLANs except the default VLAN. */
extern int bcm_vlan_destroy_all(
    int unit);

/* Add ports to the specified vlan. */
extern int bcm_vlan_port_add(
    int unit, 
    bcm_vlan_t vid, 
    bcm_pbmp_t pbmp, 
    bcm_pbmp_t ubmp);

/* Remove ports from a specified vlan. */
extern int bcm_vlan_port_remove(
    int unit, 
    bcm_vlan_t vid, 
    bcm_pbmp_t pbmp);

/* Retrieves a list of the member ports of an existing VLAN. */
extern int bcm_vlan_port_get(
    int unit, 
    bcm_vlan_t vid, 
    bcm_pbmp_t *pbmp, 
    bcm_pbmp_t *ubmp);

#endif /* BCM_HIDE_DISPATCHABLE */

#define BCM_VLAN_PORT_UNTAGGED      0x00000001 
#define BCM_VLAN_PORT_INGRESS_ONLY  0x00000002 
#define BCM_VLAN_PORT_EGRESS_ONLY   0x00000004 

#ifndef BCM_HIDE_DISPATCHABLE

/* Add a Gport to the specified vlan. */
extern int bcm_vlan_gport_add(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_gport_t port, 
    int flags);

/* Remove a Gport from the specified vlan. */
extern int bcm_vlan_gport_delete(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_gport_t port);

/* Remove all ports from the specified vlan. */
extern int bcm_vlan_gport_delete_all(
    int unit, 
    bcm_vlan_t vlan);

/* Get a Gport from the specified vlan. */
extern int bcm_vlan_gport_get(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_gport_t port, 
    int *flags);

/* Get all Gports from the specified vlan. */
extern int bcm_vlan_gport_get_all(
    int unit, 
    bcm_vlan_t vlan, 
    int array_max, 
    bcm_gport_t *gport_array, 
    int *flags_array, 
    int *array_size);

/* 
 * Returns an array of defined VLANs and their port bitmaps. If by pbmp,
 * only VLANs which contain at least one of the specified ports are
 * listed.
 */
extern int bcm_vlan_list(
    int unit, 
    bcm_vlan_data_t **listp, 
    int *countp);

/* 
 * Returns an array of defined VLANs and their port bitmaps. If by pbmp,
 * only VLANs which contain at least one of the specified ports are
 * listed.
 */
extern int bcm_vlan_list_by_pbmp(
    int unit, 
    bcm_pbmp_t ports, 
    bcm_vlan_data_t **listp, 
    int *countp);

/* Destroy a list returned by bcm_vlan_list. */
extern int bcm_vlan_list_destroy(
    int unit, 
    bcm_vlan_data_t *list, 
    int count);

/* Get the default VLAN ID. */
extern int bcm_vlan_default_get(
    int unit, 
    bcm_vlan_t *vid_ptr);

/* Set the default VLAN ID. */
extern int bcm_vlan_default_set(
    int unit, 
    bcm_vlan_t vid);

/* Retrieve the VTABLE STG for the specified vlan. */
extern int bcm_vlan_stg_get(
    int unit, 
    bcm_vlan_t vid, 
    bcm_stg_t *stg_ptr);

/* Update the VTABLE STG for the specified vlan. */
extern int bcm_vlan_stg_set(
    int unit, 
    bcm_vlan_t vid, 
    bcm_stg_t stg);

/* 
 * Set/get the spanning tree state for a port in the whole spanning tree
 * group that contains the specified VLAN.
 */
extern int bcm_vlan_stp_get(
    int unit, 
    bcm_vlan_t vid, 
    bcm_port_t port, 
    int *stp_state);

/* 
 * Set/get the spanning tree state for a port in the whole spanning tree
 * group that contains the specified VLAN.
 */
extern int bcm_vlan_stp_set(
    int unit, 
    bcm_vlan_t vid, 
    bcm_port_t port, 
    int stp_state);

/* Set spanning tree state for a port over a vlan vector. */
extern int bcm_vlan_vector_stp_set(
    int unit, 
    bcm_vlan_vector_t vlan_vector, 
    bcm_port_t port, 
    int stp_state);

#endif /* BCM_HIDE_DISPATCHABLE */

/* VLAN Action definitions. */
typedef enum bcm_vlan_action_e {
    bcmVlanActionNone,      /* Do not modify. */
    bcmVlanActionAdd,       /* Add VLAN tag. */
    bcmVlanActionReplace,   /* Replace VLAN tag. */
    bcmVlanActionDelete,    /* Delete VLAN tag. */
    bcmVlanActionCopy       /* Copy VLAN tag. */
} bcm_vlan_action_t;

/* VLAN Pcp Action definitions. */
typedef enum bcm_vlan_pcp_action_e {
    bcmVlanPcpActionNone,               /* Do not modify. */
    bcmVlanPcpActionMapped,             /* Use TC/DP mapped PCP. */
    bcmVlanPcpActionIngressInnerPcp,    /* Use incoming packet's CTag PCP. */
    bcmVlanPcpActionIngressOuterPcp,    /* Use incoming packet's Stag PCP. */
    bcmVlanPcpActionPortDefault         /* Use port default PCP. */
} bcm_vlan_pcp_action_t;

/* Initialize a VLAN tag action set structure. */
typedef struct bcm_vlan_action_set_s {
    bcm_vlan_t new_outer_vlan;          /* New outer VLAN for Add/Replace
                                           actions. */
    bcm_vlan_t new_inner_vlan;          /* New inner VLAN for Add/Replace
                                           actions. */
    uint8 new_inner_pkt_prio;           /* New inner packet priority for
                                           Add/Replace actions. */
    uint8 new_outer_cfi;                /* New outer packet CFI for Add/Replace
                                           actions. */
    uint8 new_inner_cfi;                /* New inner packet CFI for Add/Replace
                                           actions. */
    bcm_if_t ingress_if;                /* L3 Ingress Interface. */
    int priority;                       /* Internal or packet priority. */
    bcm_vlan_action_t dt_outer;         /* Outer-tag action for double-tagged
                                           packets. */
    bcm_vlan_action_t dt_outer_prio;    /* Outer-priority-tag action for
                                           double-tagged packets. */
    bcm_vlan_action_t dt_outer_pkt_prio; /* Outer packet priority action for
                                           double-tagged packets. */
    bcm_vlan_action_t dt_outer_cfi;     /* Outer packet CFI action for
                                           double-tagged packets. */
    bcm_vlan_action_t dt_inner;         /* Inner-tag action for double-tagged
                                           packets. */
    bcm_vlan_action_t dt_inner_prio;    /* Inner-priority-tag action for
                                           double-tagged packets. */
    bcm_vlan_action_t dt_inner_pkt_prio; /* Inner packet priority action for
                                           double-tagged packets. */
    bcm_vlan_action_t dt_inner_cfi;     /* Inner packet CFI action for
                                           double-tagged packets. */
    bcm_vlan_action_t ot_outer;         /* Outer-tag action for
                                           single-outer-tagged packets. */
    bcm_vlan_action_t ot_outer_prio;    /* Outer-priority-tag action for
                                           single-outer-tagged packets. */
    bcm_vlan_action_t ot_outer_pkt_prio; /* Outer packet priority action for
                                           single-outer-tagged packets. */
    bcm_vlan_action_t ot_outer_cfi;     /* Outer packet CFI action for
                                           single-outer-tagged packets. */
    bcm_vlan_action_t ot_inner;         /* Inner-tag action for
                                           single-outer-tagged packets. */
    bcm_vlan_action_t ot_inner_pkt_prio; /* Inner packet priority action for
                                           single-outer-tagged packets. */
    bcm_vlan_action_t ot_inner_cfi;     /* Inner packet CFI action for
                                           single-outer-tagged packets. */
    bcm_vlan_action_t it_outer;         /* Outer-tag action for
                                           single-inner-tagged packets. */
    bcm_vlan_action_t it_outer_pkt_prio; /* Outer packet priority action for
                                           single-inner-tagged packets. */
    bcm_vlan_action_t it_outer_cfi;     /* Outer packet CFI action for
                                           single-inner-tagged packets. */
    bcm_vlan_action_t it_inner;         /* Inner-tag action for
                                           single-inner-tagged packets. */
    bcm_vlan_action_t it_inner_prio;    /* Inner-priority-tag action for
                                           single-inner-tagged packets. */
    bcm_vlan_action_t it_inner_pkt_prio; /* Inner packet priority action for
                                           single-inner-tagged packets. */
    bcm_vlan_action_t it_inner_cfi;     /* Inner packet CFI action for
                                           single-inner-tagged packets. */
    bcm_vlan_action_t ut_outer;         /* Outer-tag action for untagged
                                           packets. */
    bcm_vlan_action_t ut_outer_pkt_prio; /* Outer packet priority action for
                                           untagged packets. */
    bcm_vlan_action_t ut_outer_cfi;     /* Outer packet CFI action for untagged
                                           packets. */
    bcm_vlan_action_t ut_inner;         /* Inner-tag action for untagged
                                           packets. */
    bcm_vlan_action_t ut_inner_pkt_prio; /* Inner packet priority action for
                                           untagged packets. */
    bcm_vlan_action_t ut_inner_cfi;     /* Inner packet CFI action for untagged
                                           packets. */
    bcm_vlan_pcp_action_t outer_pcp;    /* Outer tag's pcp field action of
                                           outgoing packets. */
    bcm_vlan_pcp_action_t inner_pcp;    /* Inner tag's pcp field action of
                                           outgoing packets. */
    bcm_policer_t policer_id;           /* Base policer to be used */
} bcm_vlan_action_set_t;

/* Initialize a VLAN tag action set structure. */
extern void bcm_vlan_action_set_t_init(
    bcm_vlan_action_set_t *action);

#ifndef BCM_HIDE_DISPATCHABLE

/* Get or set the port's default VLAN tag actions. */
extern int bcm_vlan_port_default_action_get(
    int unit, 
    bcm_port_t port, 
    bcm_vlan_action_set_t *action);

/* Get or set the port's default VLAN tag actions. */
extern int bcm_vlan_port_default_action_set(
    int unit, 
    bcm_port_t port, 
    bcm_vlan_action_set_t *action);

/* Delete the port's default VLAN tag action. */
extern int bcm_vlan_port_default_action_delete(
    int unit, 
    bcm_port_t port);

/* Get or set the egress default VLAN tag actions. */
extern int bcm_vlan_port_egress_default_action_get(
    int unit, 
    bcm_port_t port, 
    bcm_vlan_action_set_t *action);

/* Get or set the egress default VLAN tag actions. */
extern int bcm_vlan_port_egress_default_action_set(
    int unit, 
    bcm_port_t port, 
    bcm_vlan_action_set_t *action);

/* Deletes the egress default VLAN tag actions. */
extern int bcm_vlan_port_egress_default_action_delete(
    int unit, 
    bcm_port_t port);

/* 
 * Add protocol based VLAN with specified action. If the entry already
 * exists, update the action.
 */
extern int bcm_vlan_port_protocol_action_add(
    int unit, 
    bcm_port_t port, 
    bcm_port_frametype_t frame, 
    bcm_port_ethertype_t ether, 
    bcm_vlan_action_set_t *action);

/* Get protocol based VLAN action. */
extern int bcm_vlan_port_protocol_action_get(
    int unit, 
    bcm_port_t port, 
    bcm_port_frametype_t frame, 
    bcm_port_ethertype_t ether, 
    bcm_vlan_action_set_t *action);

/* Delete protocol based VLAN action. */
extern int bcm_vlan_port_protocol_action_delete(
    int unit, 
    bcm_port_t port, 
    bcm_port_frametype_t frame, 
    bcm_port_ethertype_t ether);

/* Delete all protocol based VLAN actions. */
extern int bcm_vlan_port_protocol_action_delete_all(
    int unit, 
    bcm_port_t port);

#endif /* BCM_HIDE_DISPATCHABLE */

/* vlan_port_protocol_action_traverse_cb */
typedef int (*bcm_vlan_port_protocol_action_traverse_cb)(
    int unit, 
    bcm_port_t port, 
    bcm_port_frametype_t frame, 
    bcm_port_ethertype_t ether, 
    bcm_vlan_action_set_t *action, 
    void *user_data);

#ifndef BCM_HIDE_DISPATCHABLE

/* 
 * Traverse over vlan ip actions, which are used for VLAN
 *             tag/s assignment to untagged packets.
 */
extern int bcm_vlan_port_protocol_action_traverse(
    int unit, 
    bcm_vlan_port_protocol_action_traverse_cb cb, 
    void *user_data);

/* 
 * Add an association from MAC address to VLAN, used  for VLAN tag
 *             assignment to untagged packets.
 */
extern int bcm_vlan_mac_add(
    int unit, 
    bcm_mac_t mac, 
    bcm_vlan_t vid, 
    int prio);

/* Remove an association from MAC address to VLAN. */
extern int bcm_vlan_mac_delete(
    int unit, 
    bcm_mac_t mac);

/* Remove all associations from MAC addresses to VLAN. */
extern int bcm_vlan_mac_delete_all(
    int unit);

#endif /* BCM_HIDE_DISPATCHABLE */

/* vlan_mac_action_traverse_cb */
typedef int (*bcm_vlan_mac_action_traverse_cb)(
    int unit, 
    bcm_mac_t mac, 
    bcm_vlan_action_set_t *action, 
    void *user_data);

#ifndef BCM_HIDE_DISPATCHABLE

/* 
 * Traverse over vlan mac actions, which are used for VLAN
 *             tag/s assignment to untagged packets.
 */
extern int bcm_vlan_mac_action_traverse(
    int unit, 
    bcm_vlan_mac_action_traverse_cb cb, 
    void *user_data);

/* 
 * Add an association from MAC address to VLAN actions, which are
 *             used for VLAN tag/s assignment to untagged packets.
 */
extern int bcm_vlan_mac_action_add(
    int unit, 
    bcm_mac_t mac, 
    bcm_vlan_action_set_t *action);

/* 
 * Retrive an association from MAC address to VLAN actions, which
 *             are used for VLAN tag assignment to untagged packets.
 */
extern int bcm_vlan_mac_action_get(
    int unit, 
    bcm_mac_t mac, 
    bcm_vlan_action_set_t *action);

/* 
 * Remove an association from MAC address to VLAN actions, which
 *             are used for VLAN tag assignment to untagged packets.
 */
extern int bcm_vlan_mac_action_delete(
    int unit, 
    bcm_mac_t mac);

/* 
 * Remove all MAC addresses to VLAN actions associations.
 *             Mac to VLAN actions are used for VLAN tag assignment
 *             to untagged packets.
 */
extern int bcm_vlan_mac_action_delete_all(
    int unit);

#endif /* BCM_HIDE_DISPATCHABLE */

/* 
 * VLAN translation selection
 * 
 * For chips supporting VLAN translation on a HiGig port, use the
 * following to construct a value to pass to
 * bcm_vlan_translate_add/delete routines as "port."
 */
#define BCM_VLAN_TRANSLATE_PORTMOD_MOD_SHIFT 16         
#define BCM_VLAN_TRANSLATE_PORTMOD_PORT_MASK \
    ((1 << BCM_VLAN_TRANSLATE_PORTMOD_MOD_SHIFT) - 1) 
#define BCM_VLAN_TRANSLATE_PORTMOD(port, mod_id)  \
    ((port) | (((mod_id) + 1) << BCM_VLAN_TRANSLATE_PORTMOD_MOD_SHIFT)) 

#ifndef BCM_HIDE_DISPATCHABLE

/* Add an entry to the VLAN Translation table. */
extern int bcm_vlan_translate_add(
    int unit, 
    int port, 
    bcm_vlan_t old_vid, 
    bcm_vlan_t new_vid, 
    int prio);

/* Add an entry to the VLAN Translation table. */
extern int bcm_vlan_translate_get(
    int unit, 
    int port, 
    bcm_vlan_t old_vid, 
    bcm_vlan_t *new_vid, 
    int *prio);

/* Delete an entry or entries from the VLAN Translation table. */
extern int bcm_vlan_translate_delete(
    int unit, 
    int port, 
    bcm_vlan_t old_vid);

/* Remove all entries from the VLAN Translation table. */
extern int bcm_vlan_translate_delete_all(
    int unit);

#endif /* BCM_HIDE_DISPATCHABLE */

/* Key types for vlan translation lookup. */
typedef enum bcm_vlan_translate_key_e {
    bcmVlanTranslateKeyInvalid,         /* Invalid Key Type. */
    bcmVlanTranslateKeyDouble,          /* Use O-VID[11:0] and I-VID[11:0]. */
    bcmVlanTranslateKeyOuter,           /* Use O-VID[11:0] */
    bcmVlanTranslateKeyInner,           /* Use I-VID[11:0] */
    bcmVlanTranslateKeyOuterTag,        /* Use O-TAG[15:0] */
    bcmVlanTranslateKeyInnerTag,        /* Use I-TAG[15:0] */
    bcmVlanTranslateKeyOuterPri,        /* Use (VLAN-PRI, VLAN-CFI =>
                                           O-TAG[15:12]) */
    bcmVlanTranslateKeyPortDouble,      /* Use Port, O-VID[11:0] and
                                           I-VID[11:0]. */
    bcmVlanTranslateKeyPortOuter,       /* Use Port, O-VID[11:0] */
    bcmVlanTranslateKeyPortInner,       /* Use Port, I-VID[11:0] */
    bcmVlanTranslateKeyPortOuterTag,    /* Use Port, O-TAG[15:0] */
    bcmVlanTranslateKeyPortInnerTag,    /* Use Port, I-TAG[15:0] */
    bcmVlanTranslateKeyPortOuterPri     /* Use Port, (VLAN-PRI, VLAN-CFI =>
                                           O-TAG[15:12]) */
} bcm_vlan_translate_key_t;

#ifndef BCM_HIDE_DISPATCHABLE

/* Add an entry to the VLAN Translation table and assign VLAN actions. */
extern int bcm_vlan_translate_action_add(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_translate_key_t key_type, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_vlan_action_set_t *action);

/* Get an entry to the VLAN Translation table and assign VLAN actions. */
extern int bcm_vlan_translate_action_get(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_translate_key_t key_type, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_vlan_action_set_t *action);

/* Delete an entry from the VLAN Translation table. */
extern int bcm_vlan_translate_action_delete(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_translate_key_t key_type, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan);

/* Add an entry to the egress VLAN Translation table. */
extern int bcm_vlan_translate_egress_add(
    int unit, 
    int port, 
    bcm_vlan_t old_vid, 
    bcm_vlan_t new_vid, 
    int prio);

/* Get an entry to the egress VLAN Translation table. */
extern int bcm_vlan_translate_egress_get(
    int unit, 
    int port, 
    bcm_vlan_t old_vid, 
    bcm_vlan_t *new_vid, 
    int *prio);

/* Remove an entry or entries from the VLAN egress Translation table. */
extern int bcm_vlan_translate_egress_delete(
    int unit, 
    int port, 
    bcm_vlan_t old_vid);

/* Remove all entries from the egress VLAN Translation table. */
extern int bcm_vlan_translate_egress_delete_all(
    int unit);

/* 
 * Add an entry to the egress VLAN Translation table and assign VLAN
 * actions.
 */
extern int bcm_vlan_translate_egress_action_add(
    int unit, 
    int port_class, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_vlan_action_set_t *action);

/* 
 * Get an entry to the egress VLAN Translation table and assign VLAN
 * actions.
 */
extern int bcm_vlan_translate_egress_action_get(
    int unit, 
    int port_class, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_vlan_action_set_t *action);

/* Delete an entry from the egress VLAN Translation table. */
extern int bcm_vlan_translate_egress_action_delete(
    int unit, 
    int port_class, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan);

/* Add an entry to the VLAN Translation table for double-tagging. */
extern int bcm_vlan_dtag_add(
    int unit, 
    int port, 
    bcm_vlan_t old_vid, 
    bcm_vlan_t new_vid, 
    int prio);

/* Get an entry to the VLAN Translation table for double-tagging. */
extern int bcm_vlan_dtag_get(
    int unit, 
    int port, 
    bcm_vlan_t old_vid, 
    bcm_vlan_t *new_vid, 
    int *prio);

/* Remove an entry from the VLAN Translation table for double-tagging. */
extern int bcm_vlan_dtag_delete(
    int unit, 
    int port, 
    bcm_vlan_t old_vid);

/* Remove all entries from the VLAN Translation table for double-tagging. */
extern int bcm_vlan_dtag_delete_all(
    int unit);

/* Add a VLAN range to the VLAN Translation table. */
extern int bcm_vlan_translate_range_add(
    int unit, 
    int port, 
    bcm_vlan_t old_vid_low, 
    bcm_vlan_t old_vid_high, 
    bcm_vlan_t new_vid, 
    int int_prio);

/* Get a VLAN range to the VLAN Translation table. */
extern int bcm_vlan_translate_range_get(
    int unit, 
    int port, 
    bcm_vlan_t old_vid_low, 
    bcm_vlan_t old_vid_high, 
    bcm_vlan_t *new_vid, 
    int *int_prio);

/* Delete a VLAN range from the VLAN Translation table. */
extern int bcm_vlan_translate_range_delete(
    int unit, 
    int port, 
    bcm_vlan_t old_vid_low, 
    bcm_vlan_t old_vid_high);

/* Remove all VLAN ranges from the VLAN Translation table. */
extern int bcm_vlan_translate_range_delete_all(
    int unit);

/* Add VLAN range to the VLAN Translation table for double-tagging. */
extern int bcm_vlan_dtag_range_add(
    int unit, 
    int port, 
    bcm_vlan_t old_vid_low, 
    bcm_vlan_t old_vid_high, 
    bcm_vlan_t new_vid, 
    int int_prio);

/* Get VLAN range to the VLAN Translation table for double-tagging. */
extern int bcm_vlan_dtag_range_get(
    int unit, 
    int port, 
    bcm_vlan_t old_vid_low, 
    bcm_vlan_t old_vid_high, 
    bcm_vlan_t *new_vid, 
    int *prio);

/* 
 * Remove a VLAN range from the VLAN Translation table for
 * double-tagging.
 */
extern int bcm_vlan_dtag_range_delete(
    int unit, 
    int port, 
    bcm_vlan_t old_vid_low, 
    bcm_vlan_t old_vid_high);

/* 
 * Remove all VLAN ranges from the VLAN Translation table for
 * double-tagging.
 */
extern int bcm_vlan_dtag_range_delete_all(
    int unit);

/* bcm_vlan_translate_action_range_add */
extern int bcm_vlan_translate_action_range_add(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_t outer_vlan_low, 
    bcm_vlan_t outer_vlan_high, 
    bcm_vlan_t inner_vlan_low, 
    bcm_vlan_t inner_vlan_high, 
    bcm_vlan_action_set_t *action);

/* bcm_vlan_translate_action_range_get */
extern int bcm_vlan_translate_action_range_get(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_t outer_vlan_low, 
    bcm_vlan_t outer_vlan_high, 
    bcm_vlan_t inner_vlan_low, 
    bcm_vlan_t inner_vlan_high, 
    bcm_vlan_action_set_t *action);

/* bcm_vlan_translate_action_range_delete */
extern int bcm_vlan_translate_action_range_delete(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_t outer_vlan_low, 
    bcm_vlan_t outer_vlan_high, 
    bcm_vlan_t inner_vlan_low, 
    bcm_vlan_t inner_vlan_high);

/* bcm_vlan_translate_action_range_delete_all */
extern int bcm_vlan_translate_action_range_delete_all(
    int unit);

#endif /* BCM_HIDE_DISPATCHABLE */

/* vlan_translate_egress_action_traverse_cb */
typedef int (*bcm_vlan_translate_egress_action_traverse_cb)(
    int unit, 
    int port_class, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_vlan_action_set_t *action, 
    void *user_data);

#ifndef BCM_HIDE_DISPATCHABLE

/* Traverse vlan translate egress table */
extern int bcm_vlan_translate_egress_action_traverse(
    int unit, 
    bcm_vlan_translate_egress_action_traverse_cb cb, 
    void *user_data);

#endif /* BCM_HIDE_DISPATCHABLE */

/* vlan_translate_action_traverse_cb */
typedef int (*bcm_vlan_translate_action_traverse_cb)(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_translate_key_t key_type, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_vlan_action_set_t *action, 
    void *user_data);

#ifndef BCM_HIDE_DISPATCHABLE

/* Traverse vlan translate table */
extern int bcm_vlan_translate_action_traverse(
    int unit, 
    bcm_vlan_translate_action_traverse_cb cb, 
    void *user_data);

#endif /* BCM_HIDE_DISPATCHABLE */

/* vlan_translate_traverse_cb */
typedef int (*bcm_vlan_translate_traverse_cb)(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_t old_vlan, 
    bcm_vlan_t new_vlan, 
    int prio, 
    void *user_data);

#ifndef BCM_HIDE_DISPATCHABLE

/* Traverse vlan translate table */
extern int bcm_vlan_translate_traverse(
    int unit, 
    bcm_vlan_translate_traverse_cb cb, 
    void *user_data);

#endif /* BCM_HIDE_DISPATCHABLE */

/* vlan_translate_egress_traverse_cb */
typedef int (*bcm_vlan_translate_egress_traverse_cb)(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_t old_vlan, 
    bcm_vlan_t new_vlan, 
    int prio, 
    void *user_data);

#ifndef BCM_HIDE_DISPATCHABLE

/* Traverse vlan egress translate table */
extern int bcm_vlan_translate_egress_traverse(
    int unit, 
    bcm_vlan_translate_egress_traverse_cb cb, 
    void *user_data);

#endif /* BCM_HIDE_DISPATCHABLE */

/* vlan_dtag_traverse_cb */
typedef int (*bcm_vlan_dtag_traverse_cb)(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_t old_vlan, 
    bcm_vlan_t new_vlan, 
    int prio, 
    void *user_data);

#ifndef BCM_HIDE_DISPATCHABLE

/* Traverse vlan translate table */
extern int bcm_vlan_dtag_traverse(
    int unit, 
    bcm_vlan_dtag_traverse_cb cb, 
    void *user_data);

#endif /* BCM_HIDE_DISPATCHABLE */

/* vlan_translate_action_range_traverse_cb */
typedef int (*bcm_vlan_translate_action_range_traverse_cb)(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_t outer_vlan_low, 
    bcm_vlan_t outer_vlan_high, 
    bcm_vlan_t inner_vlan_low, 
    bcm_vlan_t inner_vlan_high, 
    bcm_vlan_action_set_t *action, 
    void *user_data);

#ifndef BCM_HIDE_DISPATCHABLE

/* Traverse vlan translate range table */
extern int bcm_vlan_translate_action_range_traverse(
    int unit, 
    bcm_vlan_translate_action_range_traverse_cb cb, 
    void *user_data);

#endif /* BCM_HIDE_DISPATCHABLE */

/* bcm_vlan_translate_range_traverse_cb */
typedef int (*bcm_vlan_translate_range_traverse_cb)(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_t old_vlan_low, 
    bcm_vlan_t old_vlan_high, 
    bcm_vlan_t new_vlan, 
    int prio, 
    void *user_data);

#ifndef BCM_HIDE_DISPATCHABLE

/* Traverse vlan translate range table */
extern int bcm_vlan_translate_range_traverse(
    int unit, 
    bcm_vlan_translate_range_traverse_cb cb, 
    void *user_data);

#endif /* BCM_HIDE_DISPATCHABLE */

/* bcm_vlan_dtag_range_traverse_cb */
typedef int (*bcm_vlan_dtag_range_traverse_cb)(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_t old_vlan_low, 
    bcm_vlan_t old_vlan_high, 
    bcm_vlan_t new_vlan, 
    int prio, 
    void *user_data);

#ifndef BCM_HIDE_DISPATCHABLE

/* Traverse vlan translate range table */
extern int bcm_vlan_dtag_range_traverse(
    int unit, 
    bcm_vlan_dtag_range_traverse_cb cb, 
    void *user_data);

/* 
 * Add an association from IP subnet to VLAN to use for assigning a VLAN
 * tag to untagged packets.
 */
extern int bcm_vlan_ip4_add(
    int unit, 
    bcm_ip_t ipaddr, 
    bcm_ip_t netmask, 
    bcm_vlan_t vid, 
    int prio);

/* Remove an association from IP subnet to VLAN. */
extern int bcm_vlan_ip4_delete(
    int unit, 
    bcm_ip_t ipaddr, 
    bcm_ip_t netmask);

/* Remove all associations from IP subnet to VLAN. */
extern int bcm_vlan_ip4_delete_all(
    int unit);

#endif /* BCM_HIDE_DISPATCHABLE */

/* Flags for the unified IPv4/IPv6 bcm_vlan_ip_t type. */
#define BCM_VLAN_SUBNET_IP6     (1 << 14)  

/* Unified IPv4/IPv6 type. */
typedef struct bcm_vlan_ip_s {
    uint32 flags; 
    bcm_ip_t ip4; 
    bcm_ip_t mask; 
    bcm_ip6_t ip6; 
    int prefix; 
    bcm_vlan_t vid; 
    int prio; 
} bcm_vlan_ip_t;

/* Initialize the bcm_vlan_ip_t structure. */
extern void bcm_vlan_ip_t_init(
    bcm_vlan_ip_t *vlan_ip);

#ifndef BCM_HIDE_DISPATCHABLE

/* 
 * Add an association from IP subnet to VLAN to use for assigning a VLAN
 * tag to untagged packets.
 */
extern int bcm_vlan_ip_add(
    int unit, 
    bcm_vlan_ip_t *vlan_ip);

/* Remove an association from IP subnet to VLAN. */
extern int bcm_vlan_ip_delete(
    int unit, 
    bcm_vlan_ip_t *vlan_ip);

/* Remove all associations from IP subnet to VLAN. */
extern int bcm_vlan_ip_delete_all(
    int unit);

/* 
 * Add an association from IP subnet to VLAN actions to use for assigning
 * VLAN tag actions to untagged packets.
 */
extern int bcm_vlan_ip_action_add(
    int unit, 
    bcm_vlan_ip_t *vlan_ip, 
    bcm_vlan_action_set_t *action);

/* 
 * Get an association from IP subnet to VLAN actions to use for assigning
 * VLAN tag actions to untagged packets.
 */
extern int bcm_vlan_ip_action_get(
    int unit, 
    bcm_vlan_ip_t *vlan_ip, 
    bcm_vlan_action_set_t *action);

/* 
 * Delete an association from IP subnet to VLAN actions to use for
 * assigning VLAN tag actions to untagged packets.
 */
extern int bcm_vlan_ip_action_delete(
    int unit, 
    bcm_vlan_ip_t *vlan_ip);

/* 
 * Delete all associations from IP subnet to VLAN actions to use for
 * assigning VLAN tag actions to untagged packets.
 */
extern int bcm_vlan_ip_action_delete_all(
    int unit);

#endif /* BCM_HIDE_DISPATCHABLE */

/* vlan_ip_action_traverse_cb */
typedef int (*bcm_vlan_ip_action_traverse_cb)(
    int unit, 
    bcm_vlan_ip_t *vlan_ip, 
    bcm_vlan_action_set_t *action, 
    void *user_data);

#ifndef BCM_HIDE_DISPATCHABLE

/* 
 * Traverse over vlan ip actions, which are used for VLAN
 *             tag/s assignment to untagged packets.
 */
extern int bcm_vlan_ip_action_traverse(
    int unit, 
    bcm_vlan_ip_action_traverse_cb cb, 
    void *user_data);

#endif /* BCM_HIDE_DISPATCHABLE */

/* bcm_vlan_control_t */
typedef enum bcm_vlan_control_e {
    bcmVlanDropUnknown,             /* Drop unknown/FFF VLAN pkts or send to
                                       CPU. */
    bcmVlanPreferIP4,               /* Prefer IP Subnet VLAN selection. */
    bcmVlanPreferMAC,               /* Prefer MAC VLAN selection. */
    bcmVlanShared,                  /* Shared vs. Independent VLAN Learning. */
    bcmVlanSharedID,                /* Shared Learning VLAN ID. */
    bcmVlanTranslate,               /* Chip is in VLAN translate mode. */
    bcmVlanIgnorePktTag,            /* Ignore Packet VLAN tag. Treat packet as
                                       untagged. */
    bcmVlanPreferEgressTranslate,   /* Do egress translation even if ingress FP
                                       changes the outer/inner VLAN tag(s). */
    bcmVlanPerPortTranslate,        /* Chip is in per port VLAN translate mode. */
    bcmVlanIndependentStp,          /* Directly set port,vlan stp state, igoring
                                       STG in bcm_vlan_stp_set(). */
    bcmVlanIntelligentDT,           /* Intelligent Double Tagging Mode.(BCM53115
                                       only) */
    bcmVlanTranslateMode,           /* Select modes of Vlan Translation. */
    bcmVlanBypassIgmpMld,           /* IGMP/MLD frame will bypass VLAN Ingress
                                       Filter and VLAN Egress Filter. */
    bcmVlanBypassArpDhcp,           /* ARP/DHCP frame will flood in VLAN domain
                                       and copy to CPU even CPU is not in VLAN
                                       group. */
    bcmVlanBypassMiim,              /* Enable CPU ingress frame bypass VLAN
                                       Ingress Filter and VLAN Egress Filter. */
    bcmVlanBypassMcast,             /* Enable known multicast frame bypass VLAN
                                       Ingress Filter and VLAN Egress Filter. */
    bcmVlanBypassRsvdMcast,         /* Enable reserved multicast frame bypass
                                       VLAN Ingress Filter and VLAN Egress
                                       Filter. */
    bcmVlanBypassL2UserAddr,        /* Enable L2 user address frame bypass VLAN
                                       Ingress Filter and VLAN Egress Filter. */
    bcmVlanUnknownLearn,            /* Packets whose VLAN is not registered are
                                       learned when set to 1. */
    bcmVlanUnknownToCpu,            /* Packets whose VLAN is not registered are
                                       sent to CPU when set to 1. */
    bcmVlanMemberMismatchLearn,     /* Packets' incoming port is not the member
                                       of the VLAN are learned when set to 1. */
    bcmVlanMemberMismatchToCpu      /* Packets' incoming port is not the member
                                       of the VLAN are sent to CPU when set to
                                       1. */
} bcm_vlan_control_t;

#ifndef BCM_HIDE_DISPATCHABLE

/* Set/get miscellaneous VLAN-specific chip options. */
extern int bcm_vlan_control_get(
    int unit, 
    bcm_vlan_control_t type, 
    int *arg);

/* Set/get miscellaneous VLAN-specific chip options. */
extern int bcm_vlan_control_set(
    int unit, 
    bcm_vlan_control_t type, 
    int arg);

#endif /* BCM_HIDE_DISPATCHABLE */

/* bcm_vlan_control_port_t */
typedef enum bcm_vlan_control_port_e {
    bcmVlanPortPreferIP4, 
    bcmVlanPortPreferMAC, 
    bcmVlanTranslateIngressEnable, 
    bcmVlanTranslateIngressHitDrop, 
    bcmVlanTranslateIngressMissDrop, 
    bcmVlanTranslateEgressEnable, 
    bcmVlanTranslateEgressMissDrop, 
    bcmVlanTranslateEgressMissUntaggedDrop, 
    bcmVlanLookupMACEnable, 
    bcmVlanLookupIPEnable, 
    bcmVlanPortUseInnerPri, 
    bcmVlanPortUseOuterPri, 
    bcmVlanPortVerifyOuterTpid, 
    bcmVlanPortOuterTpidSelect, 
    bcmVlanPortTranslateKeyFirst, 
    bcmVlanPortTranslateKeySecond, 
    bcmVlanTranslateEgressMissUntag, 
    bcmVlanPortIgnorePktTag, 
    bcmVlanPortUntaggedDrop, 
    bcmVlanPortPriTaggedDrop 
} bcm_vlan_control_port_t;

/* Selectors for bcmVlanPortOuterTpidSelect */
#define BCM_PORT_OUTER_TPID     0          /* Use egress port TPID as outer
                                              TPID. */
#define BCM_VLAN_OUTER_TPID     1          /* Use VLAN TPID as outer TPID. */

#ifndef BCM_HIDE_DISPATCHABLE

/* Set/get miscellaneous port-specific VLAN options. */
extern int bcm_vlan_control_port_get(
    int unit, 
    int port, 
    bcm_vlan_control_port_t type, 
    int *arg);

/* Set/get miscellaneous port-specific VLAN options. */
extern int bcm_vlan_control_port_set(
    int unit, 
    int port, 
    bcm_vlan_control_port_t type, 
    int arg);

#endif /* BCM_HIDE_DISPATCHABLE */

/* VLAN multicast flood modes. */
typedef enum bcm_vlan_mcast_flood_e {
    BCM_VLAN_MCAST_FLOOD_ALL = _SHR_PORT_MCAST_FLOOD_ALL, 
    BCM_VLAN_MCAST_FLOOD_UNKNOWN = _SHR_PORT_MCAST_FLOOD_UNKNOWN, 
    BCM_VLAN_MCAST_FLOOD_NONE = _SHR_PORT_MCAST_FLOOD_NONE, 
    BCM_VLAN_MCAST_FLOOD_COUNT = _SHR_PORT_MCAST_FLOOD_COUNT 
} bcm_vlan_mcast_flood_t;

#define BCM_VLAN_MCAST_FLOOD_STR \
{ \
    "MCAST_FLOOD_ALL", \
    "MCAST_FLOOD_UNKNOWN", \
    "MCAST_FLOOD_NONE", \
    ""  \
}

#ifndef BCM_HIDE_DISPATCHABLE

/* Set or retrieve the current vlan multicast flood behavior. */
extern int bcm_vlan_mcast_flood_get(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_vlan_mcast_flood_t *mode);

/* Set or retrieve the current vlan multicast flood behavior. */
extern int bcm_vlan_mcast_flood_set(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_vlan_mcast_flood_t mode);

#endif /* BCM_HIDE_DISPATCHABLE */

/* Per VLAN forwarding behavior. */
typedef enum bcm_vlan_forward_e {
    bcmVlanForwardBridging,             /* Switching based on MAC and VLAN. */
    bcmVlanForwardSingleCrossConnect,   /* Switching based on outer VLAN. */
    bcmVlanForwardDoubleCrossConnect    /* Switching based on outer+inner VLAN. */
} bcm_vlan_forward_t;

/* Per VLAN URPF Mode setting. */
typedef enum bcm_vlan_urpf_mode_e {
    bcmVlanUrpfDisable, /* Disable unicast RPF. */
    bcmVlanUrpfLoose,   /* Loose mode Unicast RPF. */
    bcmVlanUrpfStrict   /* Strict mode Unicast RPF. */
} bcm_vlan_urpf_mode_t;

#define BCM_VLAN_LEARN_DISABLE              0x00000001 
#define BCM_VLAN_UNKNOWN_IP6_MCAST_TOCPU    0x00000002 
#define BCM_VLAN_UNKNOWN_IP4_MCAST_TOCPU    0x00000004 
#define BCM_VLAN_IP4_DISABLE                0x00000008 
#define BCM_VLAN_IP6_DISABLE                0x00000010 
#define BCM_VLAN_IP4_MCAST_DISABLE          0x00000020 
#define BCM_VLAN_IP6_MCAST_DISABLE          0x00000040 
#define BCM_VLAN_IP4_MCAST_L2_DISABLE       0x00000080 
#define BCM_VLAN_IP6_MCAST_L2_DISABLE       0x00000100 
#define BCM_VLAN_MPLS_DISABLE               0x00000200 
#define BCM_VLAN_COSQ_ENABLE                0x00000400 
#define BCM_VLAN_IGMP_SNOOP_DISABLE         0x00000800 
#define BCM_VLAN_PIM_SNOOP_DISABLE          0x00001000 
#define BCM_VLAN_USE_FABRIC_DISTRIBUTION    0x00002000 
#define BCM_VLAN_ICMP_REDIRECT_TOCPU        0x00004000 
#define BCM_VLAN_UNKNOWN_UCAST_TOCPU        0x00008000 
#define BCM_VLAN_UNKNOWN_UCAST_DROP         0x00010000 
#define BCM_VLAN_NON_UCAST_TOCPU            0x00020000 
#define BCM_VLAN_NON_UCAST_DROP             0x00040000 
#define BCM_VLAN_L2_LOOKUP_DISABLE          0x00080000 
#define BCM_VLAN_L3_VRF_GLOBAL_DISABLE      0x00100000 
#define BCM_VLAN_MIM_TERM_DISABLE           0x00200000 
#define BCM_VLAN_L2_CLASS_ID_ONLY           0x00400000 
#define BCM_VLAN_L3_URPF_DEFAULT_ROUTE_CHECK_DISABLE 0x00800000 
#define BCM_VLAN_TRILL_IGMP_SNOOP_DISABLE   0x01000000 

/* This structure contains the configuration of a VLAN. */
typedef struct bcm_vlan_control_vlan_s {
    bcm_vrf_t vrf; 
    bcm_vlan_t forwarding_vlan;         /* Shared VLAN ID. */
    bcm_if_t ingress_if;                /* Mapped Ingress interface. */
    uint16 outer_tpid; 
    uint32 flags; 
    bcm_vlan_mcast_flood_t ip6_mcast_flood_mode; 
    bcm_vlan_mcast_flood_t ip4_mcast_flood_mode; 
    bcm_vlan_mcast_flood_t l2_mcast_flood_mode; 
    int if_class; 
    bcm_vlan_forward_t forwarding_mode; 
    bcm_vlan_urpf_mode_t urpf_mode; 
    bcm_cos_queue_t cosq; 
    bcm_fabric_distribution_t distribution_class; /* Fabric Distribution Class. */
    bcm_multicast_t broadcast_group;    /* Group to handle broadcast frames */
    bcm_multicast_t unknown_multicast_group; /* Group to handle unknown multicast
                                           frames */
    bcm_multicast_t unknown_unicast_group; /* Group to handle unknown unicast
                                           frames */
    bcm_multicast_t trill_nonunicast_group; /* Group to handle trill-domain
                                           nonunicast frames */
    bcm_trill_name_t source_trill_name; /* Source RBridge nickname per VLAN */
    int trunk_index;                    /* Trunk index for static PSC */
} bcm_vlan_control_vlan_t;

/* Initialize the bcm_vlan_control_vlan_t structure. */
extern void bcm_vlan_control_vlan_t_init(
    bcm_vlan_control_vlan_t *data);

#ifndef BCM_HIDE_DISPATCHABLE

/* Set or retrieve current vlan properties. */
extern int bcm_vlan_control_vlan_get(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_vlan_control_vlan_t *control);

/* Set or retrieve current vlan properties. */
extern int bcm_vlan_control_vlan_set(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_vlan_control_vlan_t control);

/* Set vlan_control_vlan flags over a vlan vector. */
extern int bcm_vlan_vector_flags_set(
    int unit, 
    bcm_vlan_vector_t vlan_vector, 
    uint32 flags_mask, 
    uint32 flags_value);

#endif /* BCM_HIDE_DISPATCHABLE */

/* This structure contains the configuration of a VLAN. */
typedef struct bcm_vlan_block_s {
    bcm_pbmp_t known_multicast; 
    bcm_pbmp_t unknown_multicast; 
    bcm_pbmp_t unknown_unicast; 
    bcm_pbmp_t broadcast; 
} bcm_vlan_block_t;

/* Initialize the bcm_vlan_block_t structure. */
extern void bcm_vlan_block_t_init(
    bcm_vlan_block_t *data);

#ifndef BCM_HIDE_DISPATCHABLE

/* Retrieve vlan block properties. */
extern int bcm_vlan_block_get(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_vlan_block_t *vlan_block);

/* Set vlan block properties. */
extern int bcm_vlan_block_set(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_vlan_block_t *vlan_block);

#endif /* BCM_HIDE_DISPATCHABLE */

/* Initialize a VLAN data information structure. */
extern void bcm_vlan_data_t_init(
    bcm_vlan_data_t *vlan_data);

#ifndef BCM_HIDE_DISPATCHABLE

/* bcm_vlan_cross_connect_add */
extern int bcm_vlan_cross_connect_add(
    int unit, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_gport_t port_1, 
    bcm_gport_t port_2);

/* bcm_vlan_cross_connect_delete */
extern int bcm_vlan_cross_connect_delete(
    int unit, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan);

/* bcm_vlan_cross_connect_delete_all */
extern int bcm_vlan_cross_connect_delete_all(
    int unit);

#endif /* BCM_HIDE_DISPATCHABLE */

/* bcm_vlan_cross_connect_traverse_cb */
typedef int (*bcm_vlan_cross_connect_traverse_cb)(
    int unit, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_gport_t port_1, 
    bcm_gport_t port_2, 
    void *user_data);

#ifndef BCM_HIDE_DISPATCHABLE

/* bcm_vlan_cross_connect_traverse */
extern int bcm_vlan_cross_connect_traverse(
    int unit, 
    bcm_vlan_cross_connect_traverse_cb cb, 
    void *user_data);

#endif /* BCM_HIDE_DISPATCHABLE */

/* Types of statistics that are maintained per VLAN. */
typedef enum bcm_vlan_stat_e {
    bcmVlanStatPackets,                 /* Packets that have hit the VLAN
                                           (forward/drop, L2/L3,
                                           unicast/multicast/broadcast/flood) */
    bcmVlanStatIngressPackets = bcmVlanStatPackets, /* Packets that ingress on the VLAN */
    bcmVlanStatBytes,                   /* Bytes that have hit the VLAN
                                           (forward/drop, L2/L3,
                                           unicast/multicast/broadcast/flood) */
    bcmVlanStatIngressBytes = bcmVlanStatBytes, /* Bytes that ingress on the VLAN */
    bcmVlanStatEgressPackets,           /* Packets that egress on the VLAN */
    bcmVlanStatEgressBytes,             /* Bytes that egress on the VLAN */
    bcmVlanStatForwardedPackets,        /* Packets forwarded on the VLAN (L2/L3,
                                           unicast/multicast/broadcast/flood) */
    bcmVlanStatForwardedBytes,          /* Bytes forwarded on the VLAN (L2/L3,
                                           unicast/multicast/broadcast/flood) */
    bcmVlanStatDropPackets,             /* Packets dropped on the VLAN (L2/L3,
                                           unicast/multicast/broadcast/flood) */
    bcmVlanStatDropBytes,               /* Bytes dropped on the VLAN (L2/L3,
                                           unicast/multicast/broadcast/flood) */
    bcmVlanStatUnicastPackets,          /* L2 unicast packets forwarded on the
                                           VLAN */
    bcmVlanStatUnicastBytes,            /* L2 unicast bytes forwarded on the
                                           VLAN */
    bcmVlanStatUnicastDropPackets,      /* L2 unicast packets dropped on the
                                           VLAN */
    bcmVlanStatUnicastDropBytes,        /* L2 unicast bytes dropped on the VLAN */
    bcmVlanStatNonUnicastPackets,       /* L2 multicast packets forwarded on the
                                           VLAN */
    bcmVlanStatNonUnicastBytes,         /* L2 multicast bytes forwarded on the
                                           VLAN */
    bcmVlanStatNonUnicastDropPackets,   /* L2 non-unicast packets dropped on the
                                           VLAN */
    bcmVlanStatNonUnicastDropBytes,     /* L2 non-unicast bytes dropped on the
                                           VLAN */
    bcmVlanStatL3Packets,               /* Packets delivered to L3 for
                                           forwarding on the VLAN */
    bcmVlanStatL3Bytes,                 /* Bytes delivered to L3 for forwarding
                                           on the VLAN */
    bcmVlanStatL3DropPackets,           /* Packets delivered to L3 for dropping
                                           on the VLAN */
    bcmVlanStatL3DropBytes,             /* Bytes delivered to L3 for dropping on
                                           the VLAN */
    bcmVlanStatFloodPackets,            /* L2 flood packets forwarded on the
                                           VLAN */
    bcmVlanStatFloodBytes,              /* L2 flood bytes forwarded on the VLAN */
    bcmVlanStatFloodDropPackets,        /* L2 flood packets dropped on the VLAN */
    bcmVlanStatFloodDropBytes,          /* L2 flood bytes dropped on the VLAN */
    bcmVlanStatGreenPackets,            /* Green packets forwarded on the VLAN */
    bcmVlanStatGreenBytes,              /* Green bytes forwarded on the VLAN */
    bcmVlanStatYellowPackets,           /* Yellow packets forwarded on the VLAN */
    bcmVlanStatYellowBytes,             /* Yellow bytes forwared on the VLAN */
    bcmVlanStatRedPackets,              /* Red packets forwarded on the VLAN */
    bcmVlanStatRedBytes,                /* Red bytes forwarded on the VLAN */
    bcmVlanStatCount                    /* Always last. Not a usable value. */
} bcm_vlan_stat_t;

#ifndef BCM_HIDE_DISPATCHABLE

/* Extract per-VLAN statistics from the chip. */
extern int bcm_vlan_stat_get(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_cos_t cos, 
    bcm_vlan_stat_t stat, 
    uint64 *val);

/* Extract per-VLAN statistics from the chip. */
extern int bcm_vlan_stat_get32(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_cos_t cos, 
    bcm_vlan_stat_t stat, 
    uint32 *val);

/* 
 * Set the specified statistic to the indicated value for the specified
 * VLAN.
 */
extern int bcm_vlan_stat_set(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_cos_t cos, 
    bcm_vlan_stat_t stat, 
    uint64 val);

/* 
 * Set the specified statistic to the indicated value for the specified
 * VLAN.
 */
extern int bcm_vlan_stat_set32(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_cos_t cos, 
    bcm_vlan_stat_t stat, 
    uint32 val);

/* Provide stat counter ids associated with given vlan */
extern int bcm_vlan_stat_id_get(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_vlan_stat_t stat, 
    uint32 *stat_counter_id);

/* Enable/disable collection of statistics on the indicated VLAN. */
extern int bcm_vlan_stat_enable_set(
    int unit, 
    bcm_vlan_t vlan, 
    int enable);

/* Get 64-bit counter value for multiple VLAN statistic types. */
extern int bcm_vlan_stat_multi_get(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_cos_t cos, 
    int nstat, 
    bcm_vlan_stat_t *stat_arr, 
    uint64 *value_arr);

/* Get lower 32-bit counter value for multiple VLAN statistic types. */
extern int bcm_vlan_stat_multi_get32(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_cos_t cos, 
    int nstat, 
    bcm_vlan_stat_t *stat_arr, 
    uint32 *value_arr);

/* Set 64-bit counter value for multiple VLAN statistic types. */
extern int bcm_vlan_stat_multi_set(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_cos_t cos, 
    int nstat, 
    bcm_vlan_stat_t *stat_arr, 
    uint64 *value_arr);

/* Set lower 32-bit counter value for multiple VLAN statistic types. */
extern int bcm_vlan_stat_multi_set32(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_cos_t cos, 
    int nstat, 
    bcm_vlan_stat_t *stat_arr, 
    uint32 *value_arr);

/* Extract ingress VLAN translation statistics from the chip. */
extern int bcm_vlan_translate_stat_get(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_translate_key_t key_type, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_vlan_stat_t stat, 
    uint64 *val);

/* Extract ingress VLAN translation statistics from the chip. */
extern int bcm_vlan_translate_stat_get32(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_translate_key_t key_type, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_vlan_stat_t stat, 
    uint32 *val);

/* 
 * Provide stat counter ids associated with given ingress vlan translate
 * table
 */
extern int bcm_vlan_translate_stat_id_get(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_translate_key_t key_type, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_vlan_stat_t stat, 
    uint32 *stat_counter_id);

/* 
 * Set the specified statistic to the indicated value for the specified
 * ingress VLAN translation.
 */
extern int bcm_vlan_translate_stat_set(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_translate_key_t key_type, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_vlan_stat_t stat, 
    uint64 val);

/* 
 * Set the specified statistic to the indicated value for the specified
 * ingress VLAN translation.
 */
extern int bcm_vlan_translate_stat_set32(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_translate_key_t key_type, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_vlan_stat_t stat, 
    uint32 val);

/* 
 * Enable/disable collection of statistics on the indicated ingress VLAN
 * translation.
 */
extern int bcm_vlan_translate_stat_enable_set(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_translate_key_t key_type, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    int enable);

/* 
 * Get 64-bit counter value for multiple ingress VLAN translation
 * statistic types.
 */
extern int bcm_vlan_translate_stat_multi_get(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_translate_key_t key_type, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    int nstat, 
    bcm_vlan_stat_t *stat_arr, 
    uint64 *value_arr);

/* 
 * Get lower 32-bit counter value for multiple ingress VLAN translation
 * statistic types.
 */
extern int bcm_vlan_translate_stat_multi_get32(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_translate_key_t key_type, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    int nstat, 
    bcm_vlan_stat_t *stat_arr, 
    uint32 *value_arr);

/* 
 * Set 64-bit counter value for multiple ingress VLAN translation
 * statistic types.
 */
extern int bcm_vlan_translate_stat_multi_set(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_translate_key_t key_type, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    int nstat, 
    bcm_vlan_stat_t *stat_arr, 
    uint64 *value_arr);

/* 
 * Set lower 32-bit counter value for multiple ingress VLAN translation
 * statistic types.
 */
extern int bcm_vlan_translate_stat_multi_set32(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_translate_key_t key_type, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    int nstat, 
    bcm_vlan_stat_t *stat_arr, 
    uint32 *value_arr);

/* Extract egress VLAN translation statistics from the chip. */
extern int bcm_vlan_translate_egress_stat_get(
    int unit, 
    int port_class, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_vlan_stat_t stat, 
    uint64 *val);

/* Extract egress VLAN translation statistics from the chip. */
extern int bcm_vlan_translate_egress_stat_get32(
    int unit, 
    int port_class, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_vlan_stat_t stat, 
    uint32 *val);

/* 
 * Provide stat counter ids associated with given egress vlan translate
 * table
 */
extern int bcm_vlan_translate_egress_stat_id_get(
    int unit, 
    int port_class, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_vlan_stat_t stat, 
    uint32 *stat_counter_id);

/* 
 * Set the specified statistic to the indicated value for the specified
 * egress VLAN translation.
 */
extern int bcm_vlan_translate_egress_stat_set(
    int unit, 
    int port_class, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_vlan_stat_t stat, 
    uint64 val);

/* 
 * Set the specified statistic to the indicated value for the specified
 * egress VLAN translation.
 */
extern int bcm_vlan_translate_egress_stat_set32(
    int unit, 
    int port_class, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_vlan_stat_t stat, 
    uint32 val);

/* 
 * Enable/disable collection of statistics on the indicated egress VLAN
 * translation.
 */
extern int bcm_vlan_translate_egress_stat_enable_set(
    int unit, 
    int port_class, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    int enable);

/* 
 * Get 64-bit counter value for multiple egress VLAN translation
 * statistic types.
 */
extern int bcm_vlan_translate_egress_stat_multi_get(
    int unit, 
    int port_class, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    int nstat, 
    bcm_vlan_stat_t *stat_arr, 
    uint64 *value_arr);

/* 
 * Get lower 32-bit counter value for multiple egress VLAN translation
 * statistic types.
 */
extern int bcm_vlan_translate_egress_stat_multi_get32(
    int unit, 
    int port_class, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    int nstat, 
    bcm_vlan_stat_t *stat_arr, 
    uint32 *value_arr);

/* 
 * Set 64-bit counter value for multiple egress VLAN translation
 * statistic types.
 */
extern int bcm_vlan_translate_egress_stat_multi_set(
    int unit, 
    int port_class, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    int nstat, 
    bcm_vlan_stat_t *stat_arr, 
    uint64 *value_arr);

/* 
 * Set lower 32-bit counter value for multiple egress VLAN translation
 * statistic types.
 */
extern int bcm_vlan_translate_egress_stat_multi_set32(
    int unit, 
    int port_class, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    int nstat, 
    bcm_vlan_stat_t *stat_arr, 
    uint32 *value_arr);

/* Retrieve the Policer ID accociated with the specified VLAN. */
extern int bcm_vlan_policer_get(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_policer_t *policer_id);

/* Set the Policer ID accociated with the specified VLAN. */
extern int bcm_vlan_policer_set(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_policer_t policer_id);

/* 
 * Retrieve the Policer ID accociated with the specified VLAN and
 * physical port.
 */
extern int bcm_vlan_port_policer_get(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_port_t port, 
    bcm_policer_t *policer_id);

/* 
 * Set the Policer ID accociated with the specified VLAN and physical
 * port.
 */
extern int bcm_vlan_port_policer_set(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_port_t port, 
    bcm_policer_t policer_id);

/* 
 * Enable/Disabled Statistics Collection on VLAN and physical port or
 * GPORT
 */
extern int bcm_vlan_port_stat_enable_set(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_port_t port, 
    int enable);

/* 
 * Gets status of Statistics Collection on VLAN and physical port or
 * GPORT
 */
extern int bcm_vlan_port_stat_enable_get(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_port_t port, 
    int *enable);

/* 
 * Get the specified statistic to the indicated value for the specified
 * VLAN and port or GPORT
 */
extern int bcm_vlan_port_stat_get(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_port_t port, 
    bcm_cos_t cos, 
    bcm_vlan_stat_t stat, 
    uint64 *val);

/* 
 * Get 64-bit counter value for multiple GPORT or VLAN/port statistic
 * types.
 */
extern int bcm_vlan_port_stat_multi_get(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_port_t port, 
    bcm_cos_t cos, 
    int nstat, 
    bcm_vlan_stat_t *stat_arr, 
    uint64 *value_arr);

/* 
 * Get 32 bit specified statistic to the indicated value for the
 * specified VLAN and port or GPORT
 */
extern int bcm_vlan_port_stat_get32(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_port_t port, 
    bcm_cos_t cos, 
    bcm_vlan_stat_t stat, 
    uint32 *val);

/* 
 * Get 32-bit counter value for multiple GPORT or VLAN/port statistic
 * types.
 */
extern int bcm_vlan_port_stat_multi_get32(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_port_t port, 
    bcm_cos_t cos, 
    int nstat, 
    bcm_vlan_stat_t *stat_arr, 
    uint32 *value_arr);

/* 
 * Set the specified statistic to the indicated value for the specified
 * VLAN and port or GPORT
 */
extern int bcm_vlan_port_stat_set(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_port_t port, 
    bcm_cos_t cos, 
    bcm_vlan_stat_t stat, 
    uint64 val);

/* 
 * Set 32bit specified statistic to the indicated value for the specified
 * VLAN and port or GPORT
 */
extern int bcm_vlan_port_stat_set32(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_port_t port, 
    bcm_cos_t cos, 
    bcm_vlan_stat_t stat, 
    uint32 val);

/* 
 * set 64-bit counter value for multiple GPORT or VLAN/port statistic
 * types.
 */
extern int bcm_vlan_port_stat_multi_set(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_port_t port, 
    bcm_cos_t cos, 
    int nstat, 
    bcm_vlan_stat_t *stat_arr, 
    uint64 *value_arr);

/* 
 * set 32-bit counter value for multiple GPORT or VLAN/port statistic
 * types.
 */
extern int bcm_vlan_port_stat_multi_set32(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_port_t port, 
    bcm_cos_t cos, 
    int nstat, 
    bcm_vlan_stat_t *stat_arr, 
    uint32 *value_arr);

#endif /* BCM_HIDE_DISPATCHABLE */

/* Flags for logical layer 2 port. */
#define BCM_VLAN_PORT_REPLACE               0x00000001 /* Replace existing
                                                          entry. */
#define BCM_VLAN_PORT_WITH_ID               0x00000002 /* Add using the
                                                          specified ID. */
#define BCM_VLAN_PORT_INNER_VLAN_PRESERVE   0x00000004 /* Preserve the inner
                                                          VLAN tag (by default
                                                          it is stripped). */
#define BCM_VLAN_PORT_INNER_VLAN_ADD        0x00000008 /* Add the port vid to
                                                          untagged and
                                                          pri-tagged packets. */
#define BCM_VLAN_PORT_EGRESS_UNTAGGED       0x00000010 /* Indicates tag is
                                                          stripped on logical
                                                          port egress */
#define BCM_VLAN_PORT_EGRESS_VLAN16         0x00000020 /* Indicates a 16-bit
                                                          VLAN tag (not the
                                                          default 3-bit
                                                          priority, 1-bit CFI,
                                                          and 12-bit VLAN tag)
                                                          is added on logical
                                                          port egress */
#define BCM_VLAN_PORT_ENCAP_WITH_ID         0x00000040 /* Use the specified
                                                          encap id to allocate
                                                          and setup
                                                          encapsulation. */

/* Logical layer 2 port match criteria */
typedef enum bcm_vlan_port_match_e {
    BCM_VLAN_PORT_MATCH_INVALID,        /* Illegal. */
    BCM_VLAN_PORT_MATCH_NONE,           /* No source match criteria. */
    BCM_VLAN_PORT_MATCH_PORT,           /* {Module, Port} or Trunk. */
    BCM_VLAN_PORT_MATCH_PORT_VLAN,      /* Mod/port/trunk + outer VLAN. */
    BCM_VLAN_PORT_MATCH_PORT_VLAN_STACKED, /* Mod/port/trunk + outer/inner VLAN. */
    BCM_VLAN_PORT_MATCH_PORT_VLAN16,    /* Mod/port/trunk + 16-bit outer VLAN
                                           tag. */
    BCM_VLAN_PORT_MATCH_COUNT           /* Must be last. */
} bcm_vlan_port_match_t;

/* Layer 2 Logical port type */
typedef struct bcm_vlan_port_s {
    bcm_vlan_port_match_t criteria; /* Match criteria. */
    uint32 flags;                   /* BCM_VLAN_PORT_xxx. */
    bcm_vlan_t vsi;                 /* Populated for bcm_vlan_port_find only */
    bcm_vlan_t match_vlan;          /* Outer VLAN ID to match. */
    bcm_vlan_t match_inner_vlan;    /* Inner VLAN ID to match. */
    bcm_gport_t port;               /* Gport: local or remote Physical or
                                       logical gport. */
    bcm_vlan_t egress_vlan;         /* Egress Outer VLAN. */
    bcm_vlan_t egress_inner_vlan;   /* Egress Inner VLAN. */
    bcm_if_t encap_id;              /* Encapsulation Index. */
    int qos_map_id;                 /* QoS Map Index. */
    bcm_policer_t policer_id;       /* Policer ID */
    bcm_failover_t failover_id;     /* Failover Object Index. */
    bcm_gport_t failover_port_id;   /* Failover VLAN Port Identifier. */
    bcm_gport_t vlan_port_id;       /* GPORT identifier */
} bcm_vlan_port_t;

/* Initialize the VLAN port structure. */
extern void bcm_vlan_port_t_init(
    bcm_vlan_port_t *vlan_port);

#ifndef BCM_HIDE_DISPATCHABLE

/* 
 * Create a layer 2 logical port.  Places the ID in the logical port
 * descriptor if WITH_ID flag is not provided, uses the ID in the logical
 * port descriptor if WITH_ID flag specified.
 */
extern int bcm_vlan_port_create(
    int unit, 
    bcm_vlan_port_t *vlan_port);

/* Destroy a layer 2 logical port. */
extern int bcm_vlan_port_destroy(
    int unit, 
    bcm_gport_t gport);

/* Get/find a layer 2 logical port given the GPORT id or match criteria. */
extern int bcm_vlan_port_find(
    int unit, 
    bcm_vlan_port_t *vlan_port);

#endif /* BCM_HIDE_DISPATCHABLE */

/* Flags for bcm_vlan_queue_map_create(). */
#define BCM_VLAN_QUEUE_MAP_WITH_ID          0x0001     
#define BCM_VLAN_QUEUE_MAP_REPLACE          0x0002     
#define BCM_VLAN_QUEUE_MAP_INNER_PKT_PRI    0x0004     
#define BCM_VLAN_QUEUE_MAP_OUTER_PKT_PRI    0x0008     

#ifndef BCM_HIDE_DISPATCHABLE

/* Create a VLAN queue map entry. */
extern int bcm_vlan_queue_map_create(
    int unit, 
    uint32 flags, 
    int *qmid);

/* Delete a VLAN queue map entry. */
extern int bcm_vlan_queue_map_destroy(
    int unit, 
    int qmid);

/* Delete all VLAN queue map entries. */
extern int bcm_vlan_queue_map_destroy_all(
    int unit);

/* Set a VLAN queue map entry. */
extern int bcm_vlan_queue_map_set(
    int unit, 
    int qmid, 
    int pkt_pri, 
    int cfi, 
    int queue, 
    int color);

/* Get a VLAN queue map entry. */
extern int bcm_vlan_queue_map_get(
    int unit, 
    int qmid, 
    int pkt_pri, 
    int cfi, 
    int *queue, 
    int *color);

/* Attach a queue map object to a VLAN or VFI. */
extern int bcm_vlan_queue_map_attach(
    int unit, 
    bcm_vlan_t vlan, 
    int qmid);

/* Get the queue map object which is attached to a VLAN or VFI. */
extern int bcm_vlan_queue_map_attach_get(
    int unit, 
    bcm_vlan_t vlan, 
    int *qmid);

/* Detach a queue map object from a VLAN or VFI. */
extern int bcm_vlan_queue_map_detach(
    int unit, 
    bcm_vlan_t vlan);

/* Detach queue map objects from all VLAN or VFI. */
extern int bcm_vlan_queue_map_detach_all(
    int unit);

/* Attach   counter entries to the given vlan */
extern int bcm_vlan_stat_attach(
    int unit, 
    bcm_vlan_t vlan, 
    uint32 stat_counter_id);

/* Detach   counter entries to the given vlan */
extern int bcm_vlan_stat_detach(
    int unit, 
    bcm_vlan_t vlan);

/* 
 * Get the specified statistic to the indicated value for the specified
 * VLAN
 */
extern int bcm_vlan_stat_counter_get(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_vlan_stat_t stat, 
    uint32 num_entries, 
    uint32 *counter_indexes, 
    bcm_stat_value_t *counter_values);

/* 
 * Set the specified statistic to the indicated value for the specified
 * VLAN
 */
extern int bcm_vlan_stat_counter_set(
    int unit, 
    bcm_vlan_t vlan, 
    bcm_vlan_stat_t stat, 
    uint32 num_entries, 
    uint32 *counter_indexes, 
    bcm_stat_value_t *counter_values);

/* Attach   counters entries for the given ingress vlan translation table */
extern int bcm_vlan_translate_stat_attach(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_translate_key_t key_type, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    uint32 stat_counter_id);

/* Detach   counters entries for the given ingress vlan translation table */
extern int bcm_vlan_translate_stat_detach(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_translate_key_t key_type, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan);

/* Get   counter values from ingress vlan translation table */
extern int bcm_vlan_translate_stat_counter_get(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_translate_key_t key_type, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_vlan_stat_t stat, 
    uint32 num_entries, 
    uint32 *counter_indexes, 
    bcm_stat_value_t *counter_values);

/* Set counter values into a ingress vlan translation table */
extern int bcm_vlan_translate_stat_counter_set(
    int unit, 
    bcm_gport_t port, 
    bcm_vlan_translate_key_t key_type, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_vlan_stat_t stat, 
    uint32 num_entries, 
    uint32 *counter_indexes, 
    bcm_stat_value_t *counter_values);

/* Attach counters for the given egress vlan translation table. */
extern int bcm_vlan_translate_egress_stat_attach(
    int unit, 
    int port_class, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    uint32 stat_counter_id);

/* Detach counters for the given egress vlan translation table. */
extern int bcm_vlan_translate_egress_stat_detach(
    int unit, 
    int port_class, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan);

/* Get counter values from egress vlan translation table. */
extern int bcm_vlan_translate_egress_stat_counter_get(
    int unit, 
    int port_class, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_vlan_stat_t stat, 
    uint32 num_entries, 
    uint32 *counter_indexes, 
    bcm_stat_value_t *counter_values);

/* Set counter values from egress vlan translation table . */
extern int bcm_vlan_translate_egress_stat_counter_set(
    int unit, 
    int port_class, 
    bcm_vlan_t outer_vlan, 
    bcm_vlan_t inner_vlan, 
    bcm_vlan_stat_t stat, 
    uint32 num_entries, 
    uint32 *counter_indexes, 
    bcm_stat_value_t *counter_values);

#endif /* BCM_HIDE_DISPATCHABLE */

#endif /* __BCM_VLAN_H__ */
